//
// Created by Administrator on 2021/5/21.
//

#include "iostream"

using namespace std;

int main(){

    int arr[] = {4, 2, 8, 0, 1, 3, 5, 7, 9};

    cout << "before sort: " << endl;
    for (int i = 0; i < 9; i++) {
        cout << arr[i] << " ";
    }
    cout << endl;

    for (int i = 0; i < 9 - 1 ; i++) {
        for (int j = 0; j < 9 - 1 - i; ++j) {
            if (arr[j] > arr[j+1]){
                int temp = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = temp;
            }
        }
    }
    cout << "after sort: " << endl;
    for (int i = 0; i < 9; i++) {
        cout << arr[i] << " ";
    }
    cout << endl;

    system("pause");

    return 0;
}